package com.ruoyi.web.controller.wxqy.mobile;

import com.ruoyi.common.constant.ErrorConstants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.NumberUtils;
import com.ruoyi.common.utils.StrUtils;
import com.ruoyi.qywx.model.vo.mvb.MvSurveyAnswer;
import com.ruoyi.qywx.service.inters.SurveyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author : hcl
 * @Date : 2023/9/18 14:20
 */
@RestController
@RequestMapping("/wxqy/mvb")
public class ActivityMobildController {
    @Autowired
    private SurveyService surveyService;

    @GetMapping("/survey/question")
    private AjaxResult question(Long t, String sign, String u) {
        if (StrUtils.isEmpty(sign) || StrUtils.isEmpty(u)) {
            return AjaxResult.error(ErrorConstants.PARAMS_ERR);
        }
        return surveyService.selectSurveyBySign(t, sign, u);
    }

    @PostMapping("/survey/answer")
    public AjaxResult surveyAnswer(@RequestBody MvSurveyAnswer answer) {
        if (StrUtils.isEmpty(answer.getSign())
                || NumberUtils.isFalse(answer.getId())
                || StrUtils.isEmpty(answer.getUserUUID())
        ) {
            return AjaxResult.error(ErrorConstants.PARAMS_ERR);
        }
        return surveyService.userAnswer(answer);
    }
}
